<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
        <infopost-request>
            <xsl:for-each select="TXLife/TXLifeRequest">
                <request-head>
                    <trans-id>
                        <xsl:value-of select="TransRefGUID"/>
                    </trans-id>
                    <trans-type>102</trans-type>
                    <insu-id>
                        <xsl:value-of select="OLifEExtension/CarrierCode"/>
                    </insu-id>
                    <trans-date>
                        <xsl:value-of select="translate(string(TransExeDate),'-','')"/>
                    </trans-date>
                    <trans-time>
                        <xsl:value-of select="translate(substring(TransExeTime,1,8),':','')"/>
                    </trans-time>
                    <area>
                        <xsl:value-of select="OLifEExtension/RegionCode"/>
                    </area>
                    <branch>
                        
                    </branch>
                    <bank>
                        <xsl:value-of select="OLifEExtension/BankCode"/>
                    </bank>
                    <post>
                        <xsl:value-of select="OLifEExtension/Branch"/>
                    </post>
                    <agency-hand>
                        <xsl:value-of select="/TXLife/TXLifeRequest/OLifEExtension/Teller"/>
                    </agency-hand>
                    <authorized>root</authorized>
                    <source-type>
                       <xsl:value-of select="OLifEExtension/SourceType"/>
                    </source-type>
                    <column8>
                        <xsl:value-of select="OLifE/Holding/Policy/BankManagerName"/>
                    </column8>
                </request-head>
                <request-newbiz>
                    <request-underwriting>
                        <application>
                            <xsl:for-each select="OLifE/Holding[Policy]">
                                <!--Variable: 权益信息ID-->
                                <xsl:variable name="HoldingID">
                                    <xsl:value-of select="./@id"/>
                                </xsl:variable>
                                <!--Variable: 权益对应的投保人ID-->
                                <xsl:variable name="PhID">
                                    <xsl:value-of select="//Relation[@OriginatingObjectID=string($HoldingID) and OriginatingObjectType/@tc='4' and RelationRoleCode/@tc='80' ][1]/@RelatedObjectID"/>
                                </xsl:variable>
                                <!--Variable: 权益对应的主被保人ID-->
                                <xsl:variable name="MainLaID">
                                    <xsl:value-of select="//Relation[@OriginatingObjectID=string($HoldingID) and OriginatingObjectType/@tc='4' and RelationRoleCode/@tc='81' ][1]/@RelatedObjectID"/>
                                </xsl:variable>
                                <!--Variable: 投保人和被保人关系ID-->
                                <xsl:variable name="MainRelation">
                                    <xsl:value-of select="../Relation[(@OriginatingObjectID=string($PhID) and @RelatedObjectID=string($MainLaID))][1]/RelationRoleCode/@tc"/>
                                </xsl:variable>
                                <!--Variable: 被保人和投保人关系ID-->
                                <xsl:variable name="MainRelation1">
                                    <xsl:value-of select="../Relation[(@OriginatingObjectID=string($MainLaID) and @RelatedObjectID=string($PhID))][1]/RelationRoleCode/@tc"/>
                                </xsl:variable>
                                <apply-code>
                                    <xsl:value-of select="Policy/ApplicationInfo/HOAppFormNumber"/>
                                </apply-code>
                                <apply-date>
                                    <xsl:value-of select="translate(string(Policy/ApplicationInfo/SubmissionDate),'-','')"/>
                                </apply-date>
                                <!--销售方式   代码   1字节-->
                                <sell-way>3</sell-way>
                                <!--投保单类型 代码 1字节 缺省为3 银代-->
                                <policy-type>3</policy-type>
                                <!--投保性质   代码    缺省为2-->
                                <group-single>2</group-single>
                                <!--分行代码   代码    20字节   银行险用-->
                                <branch-bank>
                                    <xsl:value-of select="/TXLife/TXLifeRequest/OLifEExtension/BankCode"/>
                                </branch-bank>
                                <!--网点代码   字符    20字节   银行险用-->
                                <agency-code>
                                    <xsl:value-of select="/TXLife/TXLifeRequest/OLifEExtension/Branch"/>
                                </agency-code>
                                <!--经办人     字符    10字节   银行险用-->
                                <agency-hand>
                                    <xsl:value-of select="/TXLife/TXLifeRequest/OLifEExtension/Teller"/>
                                </agency-hand>
                                <!--开户银行   代码    20字节 个险首期为银行转账或银险用-->
                                <bank-code>202</bank-code>
                                <!--帐号类型   代码    1字节   缺省为7 个险首期为银行转账或银险用-->
                                <account-type>7</account-type>
                                <!--账号所有人姓名 字符 50字节 默认为投保人姓名 个险首期为银行转账或银险用-->
                                <account-name>
                                    <xsl:value-of select="/TXLife/TXLifeRequest/OLifE/Party[@id=string($PhID)][1]/FullName"/>
                                </account-name>
                                <!--银行帐号   字符    40字节 个险首期为银行转账或银险用-->
                                <bank-account>
                                    <xsl:value-of select="/TXLife/TXLifeRequest/OLifE/Holding[@id='Acct_1'][1]/Banking/AccountNumber"/>
                                </bank-account>
                                <!--首期付款方式   代码    1字节   缺省为3-->
                                <pay-mode>3</pay-mode>
                                <!--续期付款方式   代码    1字节   缺省为3-->
                                <pay-next> 3</pay-next>
                                <!--保费逾期未付选择   代码    1字节   缺省为1-->
                                <overdue-manage>1</overdue-manage>
                                <!--溢缴保费处理方式   代码    1字节     缺省为1-->
                                <over-manage>1</over-manage>
                                <!--保单递送方式   代码   1字节   银行险用  缺省为1-->
                                <deliver-type>
                                    <xsl:call-template name="TlPolicyDeliveryMethod">
                                        <xsl:with-param name="MethodValue" select="Policy/OLifEExtension/PolicyDeliveryMethod"/>
                                    </xsl:call-template>
                                </deliver-type>
                                <!--币种   代码   1字节    缺省为1-->
                                <currency-code>1</currency-code>
                                <!--特别约定代码    字符    4000字节    可空-->
                                <assumpsit/>
                                <!--客户回访类型    代码    1字节    缺省为1-->
                                <answer-type>1</answer-type>
                                <!--回访电话 字符 40字节-->
                                <answer-phone/>
                                <!--回访约定  字符   1000字节 可空 -->
                                <answer-assumpsit/>
                                <!--发票号-->
                                <!--印刷号-->
                                <print-code>
                                    <xsl:value-of select="//FormInstance[@id='Form_1'][1]/ProviderFormNumber"/>
                                </print-code>
                                <!--缴费金额-->
                                <premium>
                                    <xsl:value-of select="Policy/PaymentAmt div 100"/>
                                </premium>
                                <!--<discount-prem>
                                    <xsl:value-of select="Policy/PaymentAmt"/>
                                </discount-prem>-->
                                <xsl:for-each select="../Party[@id=string($PhID)]">
                                    <policy-holder>
                                        <!--姓名        字符    20字节-->
                                        <real-name>
                                            <xsl:value-of select="FullName"/>
                                        </real-name>
                                        <!--性别        代码    1字节-->
                                        <gender>
                                            <xsl:call-template name="TlGender">
                                                <xsl:with-param name="GenderValue" select="Person/Gender/@tc"/>
                                            </xsl:call-template>
                                        </gender>
                                        <!--出生日期    yyyymmdd-->
                                        <birthday>
                                            <xsl:value-of select="translate(string(Person/BirthDate),'-','')"/>
                                        </birthday>
                                        <!--证件类型    代码    1字节-->
                                        <certi-type>
                                            <xsl:call-template name="TlCertiType">
                                                <xsl:with-param name="TypeValue" select="GovtIDTC/@tc"/>
                                            </xsl:call-template>
                                        </certi-type>
                                        <!--证件号码    字符    20字节-->
                                        <certi-code>
                                            <xsl:value-of select="GovtID"/>
                                        </certi-code>
                                        <!--婚姻状态   代码    1字节-->
                                        <marriage-id>1</marriage-id>
                                        <!--国籍 字符    3字节-->
                                        <nationality>
                                            <xsl:call-template name="TCertiTypeToNation">
                                                <xsl:with-param name="TypeValue" select="GovtIDTC/@tc"/>
                                            </xsl:call-template>
                                        </nationality>
                                        <!--种族 字符    2字节-->
                                        <race>01</race>
                                        <!--户籍   字符   100字节-->
                                        <seat-address/>
                                        <!--出生地   字符   100字节-->
                                        <homeplace>policy holder home place</homeplace>
                                        <!--现住址        字符    60字节-->
                                        <rela-address>
                                            <xsl:value-of select="Address[AddressTypeCode/@tc='1']/Line1"/>
                                        </rela-address>
                                        <!--邮编        字符    6字节-->
                                        <rela-zip>
                                            <xsl:value-of select="Address[AddressTypeCode/@tc='1']/Zip"/>
                                        </rela-zip>
                                        <!--晚间电话        字符    40字节-->
                                        <night-phone>
                                            <xsl:value-of select="Phone[PhoneTypeCode/@tc='1']/DialNumber"/>
                                        </night-phone>
                                        <!--日间电话        字符    40字节-->
                                        <day-phone>
                                            <xsl:value-of select="Phone[PhoneTypeCode/@tc='1']/DialNumber"/>
                                        </day-phone>
                                        <!--手机        字符    20字节-->
                                        <celler>
                                            <xsl:value-of select="Phone[PhoneTypeCode/@tc='3']/DialNumber"/>
                                        </celler>
                                        <!--email地址   地址中若含有'<'或'>'则不录,视为有未录入信息 -->
                                        <email>
                                            <xsl:value-of select="EMailAddress[1]/AddrLine"/>
                                        </email>
                                        <!--收费地址 (联系地址)-->
                                        <pay-address>
                                            <xsl:value-of select="Address[AddressTypeCode/@tc='1']/Line1"/>
                                        </pay-address>
                                        <!--收费邮编 (联系邮编)-->
                                        <pay-zip>
                                            <xsl:value-of select="Address[AddressTypeCode/@tc='1']/Zip"/>
                                        </pay-zip>
                                        <!--单位名称 -->
                                        <job-com/>
                                        <!--单位地址-->
                                        <job-address>
                                            <xsl:value-of select="Address[AddressTypeCode/@tc='1']/Line1"/>
                                        </job-address>
                                        <!--单位邮编-->
                                        <job-zip>
                                            <xsl:value-of select="Address[AddressTypeCode/@tc='1']/Zip"/>
                                        </job-zip>
                                        <!--行业 字符 100字节-->
                                        <industy>policy holder industy</industy>
                                        <!--职务 由告知获取-->
                                        <title>policy holder title</title>
                                        <!--职业 -->
                                        <job-name>policy holder job name</job-name>
                                        <!--兼职 -->
                                        <pt-job-name>
                                            <xsl:value-of select="Person/OccupationType/@tc"/>
                                        </pt-job-name>
                                        <!--职业代码    字符    20字节-->
                                        <job-code>
                                              <xsl:choose>
                                                            <xsl:when test="Person/OccupationType/@tc= ''">006901</xsl:when>
                                                            <xsl:otherwise>
                                                                <xsl:value-of select="Person/OccupationType/@tc"/>
                                                            </xsl:otherwise>
                                                        </xsl:choose>
                                        </job-code>
                                        <!--与主被保人关系    代码    1字节-->
                                        <relation-with-main-insured>
                                            <xsl:call-template name="TlRelationRoleCode">
                                                <xsl:with-param name="CodeValue" select="$MainRelation"/>
                                            </xsl:call-template>
                                        </relation-with-main-insured>
                                        <!--是否吸烟   代码   1字节 缺省为'n'，需根据健康告知调整-->
                                        <smoking>N</smoking>
                                        <yearly-income>
                                            <xsl:choose>
                                                <xsl:when test="Person/EstSalary!=''">
                                                    <xsl:value-of select="format-number(Person/EstSalary div 100, '################')"/>
                                                </xsl:when>
                                            </xsl:choose>
                                        </yearly-income>
                                    </policy-holder>
                                </xsl:for-each>
                                <life-assureds>
                                    <xsl:choose>
                                        <xsl:when test="$MainRelation='8'">
                                            <xsl:for-each select="../Party[@id=string($PhID)]">
                                                <life-assured>
                                                    <la-no>
                                                        <!--被保人序号    数值  2字节-->
                                                        <xsl:number value="position()"/>
                                                    </la-no>
                                                    <!--姓名        字符    20字节-->
                                                    <real-name>
                                                        <xsl:choose>
                                                            <xsl:when test="FullName != ''">
                                                                <xsl:value-of select="FullName"/>
                                                            </xsl:when>
                                                            <xsl:when test="FullName = '' and FullNamePY != ''">
                                                                <xsl:value-of select="FullNamePY"/>
                                                            </xsl:when>
                                                            <xsl:when test="FullName = '' and FullNamePY = '' and FullNameENG != ''">
                                                                <xsl:value-of select="FullNameENG"/>
                                                            </xsl:when>
                                                        </xsl:choose>
                                                    </real-name>
                                                    <!--性别        代码    1字节-->
                                                    <gender>
                                                        <xsl:call-template name="TlGender">
                                                            <xsl:with-param name="GenderValue" select="Person/Gender/@tc"/>
                                                        </xsl:call-template>
                                                    </gender>
                                                    <!--出生日期    yyyymmdd-->
                                                    <birthday>
                                                        <xsl:value-of select="translate(string(Person/BirthDate),'-','')"/>
                                                    </birthday>
                                                    <!--婚姻状态   代码    1字节-->
                                                    <marriage-id/>
                                                    <!--国籍 字符    3字节-->
                                                    <nationality>
                                                        <xsl:call-template name="TCertiTypeToNation">
                                                            <xsl:with-param name="TypeValue" select="GovtIDTC/@tc"/>
                                                        </xsl:call-template>
                                                    </nationality>
                                                    <!--种族 字符    2字节-->
                                                    <race/>
                                                    <!--出生地   字符   100字节-->
                                                    <homeplace/>
                                                    <!--户籍   字符   100字节-->
                                                    <seat-address/>
                                                    <!--证件类型    代码    1字节-->
                                                    <certi-type>
                                                        <xsl:call-template name="TlCertiType">
                                                            <xsl:with-param name="TypeValue" select="GovtIDTC/@tc"/>
                                                        </xsl:call-template>
                                                    </certi-type>
                                                    <!--证件号码    字符    20字节-->
                                                    <certi-code>
                                                        <xsl:value-of select="GovtID"/>
                                                    </certi-code>
                                                    <!--现住址        字符    60字节-->
                                                    <rela-address>
                                                        <xsl:value-of select="Address[AddressTypeCode/@tc='1']/Line1"/>
                                                    </rela-address>
                                                    <!--邮编        字符    6字节-->
                                                    <rela-zip>
                                                        <xsl:value-of select="Address[AddressTypeCode/@tc='1']/Zip"/>
                                                    </rela-zip>
                                                    <!--日间电话        字符    40字节-->
                                                    <day-phone>
                                                        <xsl:value-of select="Phone[PhoneTypeCode/@tc='1']/DialNumber"/>
                                                    </day-phone>
                                                    <!--晚间电话        字符    40字节-->
                                                    <night-phone>
                                                        <xsl:value-of select="Phone[PhoneTypeCode/@tc='1']/DialNumber"/>
                                                    </night-phone>
                                                    <!--手机        字符    20字节-->
                                                    <celler>
                                                        <xsl:value-of select="Phone[PhoneTypeCode/@tc='3']/DialNumber"/>
                                                    </celler>
                                                    <!--email地址   地址中若含有'<'或'>'则不录,视为有未录入信息 -->
                                                    <email>
                                                        <xsl:value-of select="EMailAddress[1]/AddrLine"/>
                                                    </email>
                                                    <!--单位名称 -->
                                                    <job-com/>
                                                    <!--单位地址-->
                                                    <job-address/>
                                                    <!--单位邮编-->
                                                    <job-zip/>
                                                    <industy/>
                                                    <title/>
                                                    <job-name/>
                                                    <!--兼职 -->
                                                    <pt-job-name/>
                                                    <!--职业代码    字符    20字节-->
                                                    <job-code>
                                                        <xsl:choose>
                                                            <xsl:when test="Person/OccupationType/@tc=''">006901</xsl:when>
                                                            <xsl:otherwise>
                                                                <xsl:value-of select="Person/OccupationType/@tc"/>
                                                            </xsl:otherwise>
                                                        </xsl:choose>
                                                    </job-code>
                                                    <!--与投保人关系    代码    1字节-->
                                                    <relation-with-policy-holder>1</relation-with-policy-holder>
                                                    <relation-with-main-insured>1</relation-with-main-insured>
                                                    <!--是否吸烟 代码   1字节 缺省为'n'，需根据健康告知调整-->
                                                    <smoking>N</smoking>
                                                    <social-security/>
                                                    <height/>
                                                    <weight/>
                                                </life-assured>
                                            </xsl:for-each>
                                        </xsl:when>
                                        <xsl:otherwise>
                                            <!--主被保人信息-->
                                            <xsl:for-each select="../Party[@id=string($MainLaID)]">
                                                <life-assured>
                                                    <la-no>
                                                        <!--被保人序号    数值  2字节-->
                                                        <xsl:number value="position()"/>
                                                    </la-no>
                                                    <!--姓名        字符    20字节-->
                                                    <real-name>
                                                        <xsl:choose>
                                                            <xsl:when test="FullName != ''">
                                                                <xsl:value-of select="FullName"/>
                                                            </xsl:when>
                                                            <xsl:when test="FullName = '' and FullNamePY != ''">
                                                                <xsl:value-of select="FullNamePY"/>
                                                            </xsl:when>
                                                            <xsl:when test="FullName = '' and FullNamePY = '' and FullNameENG != ''">
                                                                <xsl:value-of select="FullNameENG"/>
                                                            </xsl:when>
                                                        </xsl:choose>
                                                    </real-name>
                                                    <!--性别        代码    1字节-->
                                                    <gender>
                                                        <xsl:call-template name="TlGender">
                                                            <xsl:with-param name="GenderValue" select="Person/Gender/@tc"/>
                                                        </xsl:call-template>
                                                    </gender>
                                                    <!--出生日期    yyyymmdd-->
                                                    <birthday>
                                                        <xsl:value-of select="translate(string(Person/BirthDate),'-','')"/>
                                                    </birthday>
                                                    <!--证件类型    代码    1字节-->
                                                    <certi-type>
                                                        <xsl:call-template name="TlCertiType">
                                                            <xsl:with-param name="TypeValue" select="GovtIDTC/@tc"/>
                                                        </xsl:call-template>
                                                    </certi-type>
                                                    <!--证件号码    字符    20字节-->
                                                    <certi-code>
                                                        <xsl:value-of select="GovtID"/>
                                                    </certi-code>
                                                    <!--婚姻状态   代码    1字节-->
                                                    <marriage-id/>
                                                    <!--国籍 字符    3字节-->
                                                    <nationality>
                                                        <xsl:call-template name="TCertiTypeToNation">
                                                            <xsl:with-param name="TypeValue" select="GovtIDTC/@tc"/>
                                                        </xsl:call-template>
                                                    </nationality>
                                                    <!--种族 字符    2字节-->
                                                    <race/>
                                                    <!--户籍   字符   100字节-->
                                                    <seat-address/>
                                                    <!--出生地   字符   100字节-->
                                                    <homeplace/>
                                                    <!--现住址        字符    60字节-->
                                                    <rela-address>
                                                        <xsl:value-of select="Address[AddressTypeCode/@tc='1']/Line1"/>
                                                    </rela-address>
                                                    <!--邮编        字符    6字节-->
                                                    <rela-zip>
                                                        <xsl:value-of select="Address[AddressTypeCode/@tc='1']/Zip"/>
                                                    </rela-zip>
                                                    <!--晚间电话        字符    40字节-->
                                                    <night-phone>
                                                        <xsl:value-of select="Phone[PhoneTypeCode/@tc='1']/DialNumber"/>
                                                    </night-phone>
                                                    <!--日间电话        字符    40字节-->
                                                    <day-phone>
                                                        <xsl:value-of select="Phone[PhoneTypeCode/@tc='1']/DialNumber"/>
                                                    </day-phone>
                                                    <!--手机        字符    20字节-->
                                                    <celler>
                                                        <xsl:value-of select="Phone[PhoneTypeCode/@tc='3']/DialNumber"/>
                                                    </celler>
                                                    <!--email地址   地址中若含有'<'或'>'则不录,视为有未录入信息 -->
                                                    <email>
                                                        <xsl:value-of select="EMailAddress[1]/AddrLine"/>
                                                    </email>
                                                    <!--单位名称 -->
                                                    <job-com/>
                                                    <!--单位地址-->
                                                    <job-address>
                                                        <xsl:value-of select="Address[AddressTypeCode/@tc='1']/Line1"/>
                                                    </job-address>
                                                    <!--单位邮编-->
                                                    <job-zip>
                                                        <xsl:value-of select="Address[AddressTypeCode/@tc='1']/Zip"/>
                                                    </job-zip>
                                                    <industy>
                                                        <xsl:value-of select="Person/OccupationType/@tc"/>
                                                    </industy>
                                                    <title/>
                                                    <job-name/>
                                                    <!--兼职 -->
                                                    <pt-job-name>
                                                        <xsl:value-of select="Person/OccupationType/@tc"/>
                                                    </pt-job-name>
                                                    <job-code>
                                                    <xsl:choose>
                                                            <xsl:when test="Person/OccupationType/@tc=''">006901</xsl:when>
                                                            <xsl:otherwise>
                                                                <xsl:value-of select="Person/OccupationType/@tc"/>
                                                            </xsl:otherwise>
                                                        </xsl:choose>
                                                    </job-code>
                                                    <!--职业代码    字符    20字节
                                            <job-code>
                                                <xsl:value-of select="Person/OccupationType/@tc"/>
                                            </job-code>-->
                                                    <!--与投保人关系    代码    1字节-->
                                                    <relation-with-policy-holder>
                                                        <xsl:call-template name="TlRelationRoleCode">
                                                            <xsl:with-param name="CodeValue" select="$MainRelation1"/>
                                                        </xsl:call-template>
                                                    </relation-with-policy-holder>
                                                    <!--与主被保人关系    代码    1字节-->
                                                    <relation-with-main-insured>1</relation-with-main-insured>
                                                    <!--是否吸烟 代码   1字节 缺省为'n'，需根据健康告知调整-->
                                                    <smoking/>
                                                </life-assured>
                                            </xsl:for-each>
                                        </xsl:otherwise>
                                    </xsl:choose>
                                </life-assureds>
                                <beneficiaries>
                                    <xsl:choose>
                                        <xsl:when test="Policy/OLifEExtension/BeneficiaryIndicator='Y'">
                                            <beneficiary>
                                                <!--被保人序号    数值  2字节-->
                                                <la-no>1</la-no>
                                                <legal-bene-indi>Y</legal-bene-indi>
                                                <!--姓名-->
                                                <real-name>法定继承人</real-name>
                                                <!--性别        代码    1字节-->
                                                <gender/>
                                                <!--出生日期    yyyymmdd-->
                                                <birthday/>
                                                <!--证件类型-->
                                                <certi-type/>
                                                <!--证件号码-->
                                                <certi-code/>
                                                <certi-start-date/>
                                                <certi-end-date/>
                                                <!--受益性质  代码  1字节  缺省为2-->
                                                <bene-type>2</bene-type>
                                                <!--受益顺序    数值    2字节    缺省均为1-->
                                                <bene-order>1 </bene-order>
                                                <!--受益比例    比例    8字节    同一受益顺序下比率加和为1-->
                                                <bene-rate>100.00</bene-rate>
                                                <address/>
                                                <zip/>
                                                <job-code/>
                                                <!--与被保人关系    代码    1字节-->
                                                <relation-with-insured>1</relation-with-insured>
                                            </beneficiary>
                                        </xsl:when>
                                        <xsl:otherwise>
                                            <xsl:for-each select="../Relation[OriginatingObjectType/@tc='4' and @OriginatingObjectID=string($HoldingID) and RelationRoleCode/@tc='82' ]">
                                                <xsl:variable name="BeneficiariesID">
                                                    <xsl:value-of select="./@RelatedObjectID"/>
                                                </xsl:variable>
                                                <xsl:variable name="beneficiarySequence">
                                                    <xsl:value-of select="./Sequence"/>
                                                </xsl:variable>
                                                <xsl:variable name="interestPercent">
                                                    <xsl:value-of select="./InterestPercent"/>
                                                </xsl:variable>
                                                <xsl:for-each select="../Party[@id=string($BeneficiariesID)]">
                                                    <beneficiary>
                                                        <!--受益人序号    数值  2字节-->
                                                        <la-no/>
                                                        <!--姓名-->
                                                        <real-name>
                                                            <xsl:value-of select="FullName"/>
                                                        </real-name>
                                                        <!--性别        代码    1字节-->
                                                        <gender>
                                                            <xsl:call-template name="TlGender">
                                                                <xsl:with-param name="GenderValue" select="Person/Gender/@tc"/>
                                                            </xsl:call-template>
                                                        </gender>
                                                        <!--出生日期    yyyymmdd-->
                                                        <birthday>
                                                            <xsl:value-of select="translate(string(Person/BirthDate),'-','')"/>
                                                        </birthday>
                                                        <!--证件类型-->
                                                        <certi-type>
                                                            <xsl:call-template name="TlCertiType">
                                                                <xsl:with-param name="TypeValue" select="GovtIDTC/@tc"/>
                                                            </xsl:call-template>
                                                        </certi-type>
                                                        <!--证件号码-->
                                                        <certi-code>
                                                            <xsl:value-of select="GovtID"/>
                                                        </certi-code>
                                                        <!--是否法定受益人   字符   1字节 暂为'n'-->
                                                        <legal-bene-indi>N</legal-bene-indi>
                                                        <!--受益性质  代码  1字节  缺省为2-->
                                                        <bene-type>2</bene-type>
                                                        <!--受益顺序    数值    2字节    缺省均为1-->
                                                        <bene-order>
                                                            <xsl:value-of select="$beneficiarySequence"/>
                                                        </bene-order>
                                                        <!--受益比例    比例    8字节    同一受益顺序下比率加和为1-->
                                                        <bene-rate>
                                                            <xsl:value-of select="$interestPercent"/>
                                                        </bene-rate>
                                                        <!--与被保人关系    代码    1字节-->
                                                        <xsl:variable name="v_ben_rel" select="../Relation[(@OriginatingObjectID=string($BeneficiariesID) and @RelatedObjectID=string($MainLaID)) or(@OriginatingObjectID=string($MainLaID) and @RelatedObjectID=string($BeneficiariesID))][1]/RelationRoleCode/@tc"/>
                                                        <!--与被保人关系    代码    1字节-->
                                                        <xsl:choose>
                                                            <xsl:when test="$v_ben_rel= '1' ">
                                                                <xsl:choose>
                                                                    <xsl:when test="Person/Gender/@tc = '2' ">
                                                                        <relation-with-insured>1</relation-with-insured>
                                                                    </xsl:when>
                                                                    <xsl:when test="Person/Gender/@tc= '1' ">
                                                                        <relation-with-insured>2</relation-with-insured>
                                                                    </xsl:when>
                                                                </xsl:choose>
                                                            </xsl:when>
                                                            <xsl:when test="$v_ben_rel= '3' ">
                                                                <relation-with-insured>3</relation-with-insured>
                                                            </xsl:when>
                                                            <xsl:when test="$v_ben_rel= '99' ">
                                                                <relation-with-insured>15</relation-with-insured>
                                                            </xsl:when>
                                                            <xsl:when test="$v_ben_rel= '7' ">
                                                                <relation-with-insured>15</relation-with-insured>
                                                            </xsl:when>
                                                            <xsl:when test="$v_ben_rel= '5' ">
                                                                <relation-with-insured>15</relation-with-insured>
                                                            </xsl:when>
                                                            <xsl:when test="$v_ben_rel= '9' ">
                                                                <relation-with-insured>15</relation-with-insured>
                                                            </xsl:when>
                                                            <xsl:when test="$v_ben_rel= '2' ">
                                                                <xsl:choose>
                                                                    <xsl:when test="//OLifEExtension/SourceType != 0">
                                                                        <xsl:choose>
                                                                            <xsl:when test="Person/Gender/@tc = '1' ">
                                                                                <relation-with-insured>10</relation-with-insured>
                                                                            </xsl:when>
                                                                            <xsl:when test="Person/Gender/@tc= '2' ">
                                                                                <relation-with-insured>10</relation-with-insured>
                                                                            </xsl:when>
                                                                        </xsl:choose>
                                                                    </xsl:when>
                                                                    <xsl:otherwise>
                                                                        <xsl:choose>
                                                                            <xsl:when test="Person/Gender/@tc = '1' ">
                                                                                <relation-with-insured>5</relation-with-insured>
                                                                            </xsl:when>
                                                                            <xsl:when test="Person/Gender/@tc= '2' ">
                                                                                <relation-with-insured>4</relation-with-insured>
                                                                            </xsl:when>
                                                                        </xsl:choose>
                                                                    </xsl:otherwise>
                                                                </xsl:choose>
                                                            </xsl:when>
                                                            <xsl:when test="$v_ben_rel= '8' ">
                                                                <relation-with-insured>0</relation-with-insured>
                                                            </xsl:when>
                                                            <xsl:when test="$v_ben_rel= '4' ">
                                                                <xsl:choose>
                                                                    <xsl:when test="Person/Gender/@tc = '1' ">
                                                                        <relation-with-insured>7</relation-with-insured>
                                                                    </xsl:when>
                                                                    <xsl:when test="Person/Gender/@tc= '2' ">
                                                                        <relation-with-insured>6</relation-with-insured>
                                                                    </xsl:when>
                                                                </xsl:choose>
                                                            </xsl:when>
                                                            <xsl:when test="$v_ben_rel= '6' ">
                                                                <xsl:choose>
                                                                    <xsl:when test="Person/Gender/@tc = '1' ">
                                                                        <relation-with-insured>9</relation-with-insured>
                                                                    </xsl:when>
                                                                    <xsl:when test="Person/Gender/@tc= '2' ">
                                                                        <relation-with-insured>8</relation-with-insured>
                                                                    </xsl:when>
                                                                </xsl:choose>
                                                            </xsl:when>
                                                        </xsl:choose>
                                                    </beneficiary>
                                                </xsl:for-each>
                                            </xsl:for-each>
                                        </xsl:otherwise>
                                    </xsl:choose>
                                </beneficiaries>
                                <products>
                                    <xsl:for-each select="Policy/Life/Coverage">
                                        <product>
                                            <!--被保人序号 -->
                                            <la-no>1</la-no>
                                            <!--险种序号  代码   3字节-->
                                            <product-num>100</product-num>
                                            <!--险种代码    代码    5字节-->
                                            <product-code>
                                                <!--<xsl:call-template name="TIProductCode">
                                                    <xsl:with-param name="ModeValue" select="ProductCode"/>
                                                </xsl:call-template>-->
                                            </product-code>
                                            <!-- 外部险种编号-->
                                            <external-prd-code>
                                                <xsl:value-of select="ProductCode"/>
                                            </external-prd-code>
                                            <!--可豁免保费   字符   1字节 暂为'n'-->
                                            <is-waiver>N</is-waiver>
                                            <!--豁免险种     代码   5字节 暂为空-->
                                            <waiver-num/>
                                            <!--豁免对象 代码 1:豁免被保人 2:豁免投保人 暂为空-->
                                            <waiver-object/>
                                            <!--缴费年期类型    代码    1字节-->
                                            <charge-period>
                                                <xsl:call-template name="TlPaymentDurationMode">
                                                    <xsl:with-param name="ModeValue" select="OLifEExtension/PaymentDurationMode"/>
                                                </xsl:call-template>
                                            </charge-period>
                                            <!--缴费年期        数值    3字节-->
                                            <charge-year>
                                                <xsl:value-of select="OLifEExtension/PaymentDuration"/>
                                            </charge-year>
                                            <!--保障年期类型    代码    1字节-->
                                            <coverage-period>
                                                <xsl:call-template name="TlDurationMode">
                                                    <xsl:with-param name="ModeValue" select="OLifEExtension/DurationMode"/>
                                                </xsl:call-template>
                                            </coverage-period>
                                            <Insu-year-flag>
                                                <xsl:call-template name="TlDurationMode">
                                                    <xsl:with-param name="ModeValue" select="OLifEExtension/DurationMode"/>
                                                </xsl:call-template>
                                            </Insu-year-flag>
                                            <!--保障年期        数值    3字节-->
                                            <coverage-year>
                                                <xsl:value-of select="OLifEExtension/Duration"/>
                                            </coverage-year>
                                            <charge-mode>
                                                <xsl:call-template name="TlPaymentMode">
                                                    <xsl:with-param name="ModeValue" select="../../PaymentMode/@tc"/>
                                                </xsl:call-template>
                                            </charge-mode>
                                            <!--保额 -->
                                                <amount>
                                              <xsl:choose>
                                                    <xsl:when test="string(FaceAmt)!=''">
                                                        <xsl:value-of select="FaceAmt div 100"/>
                                                    </xsl:when>
                                                    <xsl:when test="string(InitCovAmt)!=''">
                                                        <xsl:value-of select="InitCovAmt div 100"/>
                                                    </xsl:when>
                                                    <xsl:otherwise>
                                                    </xsl:otherwise>
                                                </xsl:choose>
                                            </amount>
                                            <!--首期保费 -->
                                            <discount-prem>
                                                <xsl:choose>
                                                    <xsl:when test="string(ModalPremAmt)!=''">
                                                        <xsl:value-of select="ModalPremAmt div 100"/>
                                                    </xsl:when>
                                                    <xsl:otherwise>
                                                        <xsl:value-of select="InitCovAmt div 100"/>
                                                    </xsl:otherwise>
                                                </xsl:choose>
                                            </discount-prem>
                                            <!--保费计算方向 缺省为1-->
                                            <count-way>
                                                <xsl:choose>
                                                    <xsl:when test="string(ModalPremAmt)!=''">2</xsl:when>
                                                    <xsl:when test="string(IntialNumberOfUnits)!=''">3</xsl:when>
                                                    <xsl:otherwise>1</xsl:otherwise>
                                                </xsl:choose>
                                            </count-way>
                                            <!--红利领取方式   代码  1字节 红利险种用 缺省为1-->
                                            <bonus-choice>
                                                <xsl:call-template name="TlDivType">
                                                    <xsl:with-param name="TypeValue" select="../DivType/@tc"/>
                                                </xsl:call-template>
                                            </bonus-choice>
                                        </product>
                                    </xsl:for-each>
                                </products>
                            </xsl:for-each>
                        </application>
                    </request-underwriting>
                    <request-policy-issue>
                        <uw-trans-id/>
                        <xsl:for-each select="OLifE/Holding[Policy]">
                            <!--Variable: 权益信息ID-->
                            <xsl:variable name="HoldingID">
                                <xsl:value-of select="./@id"/>
                            </xsl:variable>
                            <apply-code>
                                <xsl:value-of select="Policy/ApplicationInfo/HOAppFormNumber"/>
                            </apply-code>
                            <!--发票号-->
                            <!--单证印刷号码-->
                            <print-code>
                                <xsl:value-of select="//FormInstance[@id='Form_1']/ProviderFormNumber"/>
                            </print-code>
                            <premium>
                                <xsl:value-of select="Policy/PaymentAmt div 100"/>
                                <!-- 
           <xsl:choose>
                   <xsl:when test="string(Policy/Life/Coverage/ModalPremAm/InitCovAmt)=''">
                       <xsl:value-of select="Policy/Life/Coverage/ModalPremAmt"/>
                   </xsl:when>
                   <xsl:otherwise>
                       <xsl:value-of select="Policy/Life/Coverage/ModalPremAm/InitCovAmt"/>
                   </xsl:otherwise>
            </xsl:choose>
           -->
                            </premium>
                        </xsl:for-each>
                    </request-policy-issue>
                </request-newbiz>
            </xsl:for-each>
        </infopost-request>
    </xsl:template>
    <xsl:template name="TlPaymentMode">
        <xsl:param name="ModeValue"/>
        <xsl:choose>
            <xsl:when test="$ModeValue=5">5</xsl:when>
            <xsl:when test="$ModeValue=2">4</xsl:when>
            <xsl:when test="$ModeValue=1">1</xsl:when>
            <xsl:when test="$ModeValue=3">2</xsl:when>
            <xsl:when test="$ModeValue=4">3</xsl:when>
            <xsl:when test="$ModeValue=6">0</xsl:when>
            <xsl:when test="$ModeValue=9">0</xsl:when>
        </xsl:choose>
    </xsl:template>
    <xsl:template name="TlPaymentMethod">
        <xsl:param name="MethodValue"/>
        <xsl:choose>
            <xsl:when test="$MethodValue=1">3</xsl:when>
            <xsl:when test="$MethodValue=2">2</xsl:when>
            <xsl:when test="$MethodValue=3">7</xsl:when>
            <xsl:when test="$MethodValue=4">1</xsl:when>
            <xsl:when test="$MethodValue=5">63</xsl:when>
            <xsl:when test="$MethodValue=6">5</xsl:when>
            <xsl:when test="$MethodValue=7">58</xsl:when>
            <xsl:when test="$MethodValue=9">0</xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="$MethodValue"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    <xsl:template name="TIProductCode">
        <xsl:param name="ModeValue"/>
        <xsl:choose>
            <xsl:when test="$ModeValue=001">0033</xsl:when>
            <xsl:when test="$ModeValue=002">1005</xsl:when>
            <xsl:when test="$ModeValue=003">0006</xsl:when>
            <xsl:when test="$ModeValue=004">0017</xsl:when>
            <xsl:when test="$ModeValue=005">1019</xsl:when>
            <xsl:when test="$ModeValue=006">1022</xsl:when>
            <xsl:when test="$ModeValue=007">1014</xsl:when>
            <xsl:when test="$ModeValue=008">1025</xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="$ModeValue"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    <xsl:template name="TlDurationMode">
        <xsl:param name="ModeValue"/>
        <xsl:choose>
            <xsl:when test="$ModeValue=1">3</xsl:when>
            <xsl:when test="$ModeValue=2">2</xsl:when>
            <xsl:when test="$ModeValue=3">4</xsl:when>
            <xsl:when test="$ModeValue=4">0</xsl:when>
            <xsl:when test="$ModeValue=5">1</xsl:when>
            <xsl:when test="$ModeValue=9">0</xsl:when>
        </xsl:choose>
    </xsl:template>
    <xsl:template name="TlPaymentDurationMode">
        <xsl:param name="ModeValue"/>
        <xsl:choose>
            <xsl:when test="$ModeValue=1">3</xsl:when>
            <xsl:when test="$ModeValue=2">2</xsl:when>
            <xsl:when test="$ModeValue=3">0</xsl:when>
            <xsl:when test="$ModeValue=5">1</xsl:when>
            <xsl:when test="$ModeValue=6">4</xsl:when>
            <xsl:when test="$ModeValue=7">0</xsl:when>
            <xsl:otherwise>0</xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    <xsl:template name="TlPolicyDeliveryMethod">
        <xsl:param name="MethodValue"/>
        <xsl:choose>
            <xsl:when test="$MethodValue=9">4</xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="$MethodValue"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    <xsl:template name="TlDivType">
        <xsl:param name="TypeValue"/>
        <xsl:choose>
            <xsl:when test="$TypeValue=2">1</xsl:when>
            <xsl:when test="$TypeValue=3">2</xsl:when>
            <xsl:when test="$TypeValue=1">3</xsl:when>
            <xsl:when test="$TypeValue=4">5</xsl:when>
            <xsl:when test="$TypeValue=6">10</xsl:when>
            <xsl:otherwise>3</xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    <xsl:template name="TlCertiType">
        <xsl:param name="TypeValue"/>
        <xsl:choose>
            <xsl:when test="$TypeValue=0">1</xsl:when>
            <xsl:when test="$TypeValue=1">3</xsl:when>
            <xsl:when test="$TypeValue=2">2</xsl:when>
            <xsl:when test="$TypeValue=3">2</xsl:when>
            <xsl:when test="$TypeValue=4">6</xsl:when>
            <xsl:when test="$TypeValue=5">9</xsl:when>
            <xsl:when test="$TypeValue=6">7</xsl:when>
            <xsl:when test="$TypeValue=7">9</xsl:when>
            <xsl:when test="$TypeValue=9">8</xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="$TypeValue"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    <xsl:template name="TCertiTypeToNation">
        <xsl:param name="TypeValue"/>
        <xsl:choose>
            <xsl:when test="$TypeValue=0">37</xsl:when>
            <xsl:when test="$TypeValue=2">37</xsl:when>
            <xsl:when test="$TypeValue=3">37</xsl:when>
            <xsl:when test="$TypeValue=6">37</xsl:when>
            <xsl:when test="$TypeValue=9">37</xsl:when>
            <xsl:otherwise>
               </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    <xsl:template name="TlGender">
        <xsl:param name="GenderValue"/>
        <xsl:choose>
            <xsl:when test="$GenderValue=1">M</xsl:when>
            <xsl:when test="$GenderValue=2">F</xsl:when>
            <xsl:when test="$GenderValue=3">N</xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="$GenderValue"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    <xsl:template name="TlRelationRoleCode">
        <xsl:param name="CodeValue"/>
        <xsl:choose>
            <xsl:when test="$CodeValue=1">3</xsl:when>
            <xsl:when test="$CodeValue=2">10</xsl:when>
            <xsl:when test="$CodeValue=3">2</xsl:when>
            <xsl:when test="$CodeValue=8">1</xsl:when>
            <xsl:when test="$CodeValue=99">7</xsl:when>
            <xsl:when test="$CodeValue=6">11</xsl:when>
            <xsl:when test="$CodeValue=4">12</xsl:when>
            <xsl:when test="$CodeValue=5">13</xsl:when>
            <xsl:when test="$CodeValue=7">14</xsl:when>
            <xsl:otherwise>7</xsl:otherwise>
        </xsl:choose>
    </xsl:template>
</xsl:stylesheet>
